﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using LightWeightORM.ORM.TableAccessor;
using SmartWarehouse.ORM.Entity;
using SmartWarehouse.Config;

namespace SmartWarehouse
{
    namespace Common
    {
        /// <summary>
        /// Summary description for AccessorFactory
        /// </summary>
        public class AccessorFactory
        {
            private static TableAccessor<SwUser> _userAccessor = null;
            public static TableAccessor<SwUser> UserAccessor
            {
                get
                {
                    if (_userAccessor == null)
                        _userAccessor = new TableAccessor<SwUser>(ConfigUtility.DbConnectionString);
                    return _userAccessor;
                }
            }

            private static TableAccessor<SwTransaction> _transactionAccessor = null;
            public static TableAccessor<SwTransaction> TransactionAcessor
            {
                get
                {
                    if (_transactionAccessor == null)
                        _transactionAccessor = new TableAccessor<SwTransaction>(ConfigUtility.DbConnectionString);
                    return _transactionAccessor;
                }
            }

            private static TableAccessor<SwProduct> _productAccessor = null;
            public static TableAccessor<SwProduct> ProductAccessor
            {
                get 
                {
                    if (_productAccessor == null)
                        _productAccessor = new TableAccessor<SwProduct>(ConfigUtility.DbConnectionString);
                    return _productAccessor;
                }
            }

            private static TableAccessor<SwMovementType> _movementTypeAccessor = null;
            public static TableAccessor<SwMovementType> MovementTypeAccessor
            {
                get
                {
                    if (_movementTypeAccessor == null)
                        _movementTypeAccessor = new TableAccessor<SwMovementType>(ConfigUtility.DbConnectionString);
                    return _movementTypeAccessor;
                }
            }

            private static TableAccessor<SwInventory> _inventoryAccessor = null;
            public static TableAccessor<SwInventory> InventoryAccessor
            {
                get 
                {
                    if (_inventoryAccessor == null)
                        _inventoryAccessor = new TableAccessor<SwInventory>(ConfigUtility.DbConnectionString);
                    return _inventoryAccessor;
                }
            }

            private static TableAccessor<SwRight> _rightAccessor = null;
            public static TableAccessor<SwRight> RightAccessor
            {
                get 
                {
                    if (_rightAccessor == null)
                        _rightAccessor = new TableAccessor<SwRight>(ConfigUtility.DbConnectionString);
                    return _rightAccessor;
                }
            }

            private static TableAccessor<SwGoodReceive> _goodReceiveAccessor = null;
            public static TableAccessor<SwGoodReceive> GoodReceiveAccessor
            {
                get
                {
                    if (_goodReceiveAccessor == null)
                        _goodReceiveAccessor = new TableAccessor<SwGoodReceive>(ConfigUtility.DbConnectionString);
                    return _goodReceiveAccessor;
                }
            }

            private static TableAccessor<SwShipment> _shipmentAccessor = null;
            public static TableAccessor<SwShipment> ShipmentAccessor
            {
                get
                {
                    if (_shipmentAccessor == null)
                        _shipmentAccessor = new TableAccessor<SwShipment>(ConfigUtility.DbConnectionString);
                    return _shipmentAccessor;
                }
            }

        }
    }
}